package o;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import androidx.viewpager.widget.ViewPager.OnPageChangeListener;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseCardBean;
import com.huawei.appmarket.framework.widget.uxwidget.hwdotspageindicator.HwTopBannerIndicator;
import com.huawei.appmarket.framework.widget.uxwidget.topbanner.TopBanner;
import com.huawei.appmarket.service.store.awk.widget.topbanner.DotsViewPager;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import o.dge.d;
import o.ejb.e;
import o.ewm.j;
import o.ewm.n;

public class eif implements OnPageChangeListener {
    private static final Double ˎ = Double.valueOf(0.8d);
    private int ʻ = 0;
    private int ʼ = 0;
    private int ʽ = 0;
    private final Context ˊ;
    private final DotsViewPager ˋ;
    private final HwTopBannerIndicator ˏ;
    private String ॱ;
    private int ॱॱ = ccz.ॱ();
    private float ᐝ = 0.0f;

    public eif(Context context, DotsViewPager dotsViewPager, HwTopBannerIndicator hwTopBannerIndicator, String str) {
        this.ˊ = context;
        this.ˋ = dotsViewPager;
        this.ˏ = hwTopBannerIndicator;
        this.ॱ = str;
        if (dotsViewPager != null) {
            this.ॱॱ = dgm.ˎ((Activity) dotsViewPager.getContext());
        }
    }

    public void onPageScrolled(int i, float f, int i2) {
        if (f != 0.0f) {
            ˎ(i, f, i2, ˎ(i, f));
        } else {
            this.ʻ = 0;
        }
    }

    private void ˎ(int i, float f, int i2, int i3) {
        if (i3 == -1 || i3 == 1) {
            int childCount = this.ˋ.getChildCount();
            for (int i4 = 0; i4 < childCount; i4++) {
                View childAt = this.ˋ.getChildAt(i4);
                if (childAt != null) {
                    ˊ(i, f, i2, i3, childAt);
                }
            }
        }
    }

    private void ˊ(int i, float f, int i2, int i3, View view) {
        Object obj = null;
        Object tag = view.getTag(j.ߺ);
        if (tag instanceof Integer) {
            boolean z;
            int intValue = ((Integer) tag).intValue();
            if (intValue == i) {
                z = true;
            } else {
                z = false;
            }
            if (i3 == 1) {
                tag = (z || (ˋ() && intValue == i + 1)) ? 1 : null;
            } else {
                if (intValue == i + 1 || (ˋ() && z)) {
                    obj = 1;
                }
                tag = obj;
            }
            if (tag != null) {
                tag = view.getTag();
                if (tag instanceof e) {
                    ˏ(f, i3, z, (e) tag);
                }
            }
        }
    }

    private void ˏ(float f, int i, boolean z, e eVar) {
        if (eVar.ˎ == null) {
            return;
        }
        if (i == 1) {
            if (z) {
                eVar.ˎ.setRightView1(f);
            } else {
                eVar.ˎ.setRightView2(f);
            }
        } else if (z) {
            eVar.ˎ.setLeftView1(f);
        } else {
            eVar.ˎ.setLeftView2(f);
        }
    }

    public void onPageScrollStateChanged(int i) {
        ॱ(i);
    }

    public void onPageScrolled(int i) {
        ˎ(i);
    }

    private boolean ˋ() {
        return epv.ʼ(this.ˊ);
    }

    private void ॱ(int i) {
        PagerAdapter ˎ = this.ˋ.getAdapter();
        if (ˎ instanceof ejb) {
            BaseCardBean ˋ = ((ejb) ˎ).ˋ(i);
            if (ˋ != null) {
                ˊ(ˋ);
                ˏ(ˋ);
            }
        }
        this.ʽ = i;
        ˋ(i);
    }

    private void ˊ(BaseCardBean baseCardBean) {
        baseCardBean.ˋˋ(this.ॱ);
        new dyk(this.ॱॱ).ॱ(baseCardBean);
    }

    private void ˏ(BaseCardBean baseCardBean) {
        String ॱˉ = baseCardBean.ॱˉ();
        dgh.onEvent(new d(ContentManager.getInstant().getContext(), n.ᐧ).ˏ(eiz.ˊ(ॱˉ + HiAnalyticsConstant.REPORT_VAL_SEPARATOR + dof.ʼ(baseCardBean.ॱॱ()).replaceAll("\\|", "#$#") + HiAnalyticsConstant.REPORT_VAL_SEPARATOR + baseCardBean.u_())).ˋ());
    }

    private void ˎ(int i) {
        if (i == 0) {
            this.ʻ = 0;
            this.ʼ = 0;
            ˋ(this.ʽ);
        }
    }

    private void ˋ(int i) {
        int childCount = this.ˋ.getChildCount();
        for (int i2 = 0; i2 < childCount; i2++) {
            View childAt = this.ˋ.getChildAt(i2);
            if (childAt != null) {
                Object tag = childAt.getTag(j.ߺ);
                if ((tag instanceof Integer) && i == ((Integer) tag).intValue()) {
                    tag = childAt.getTag();
                    if (tag instanceof e) {
                        TopBanner topBanner = ((e) tag).ˎ;
                        if (topBanner != null) {
                            topBanner.setInitialPosition();
                        }
                    }
                }
            }
        }
    }

    private int ˎ(int i, float f) {
        if (this.ʻ == 0) {
            if (this.ʽ > i) {
                this.ʼ = 1;
            } else if (this.ʽ == i) {
                this.ʼ = -1;
            }
            if (this.ˏ != null && this.ˏ.ˎ()) {
                this.ʼ = -1;
            }
            this.ʻ = 1;
        } else if (this.ʼ == 1 && ((double) (f - this.ᐝ)) < (-ˎ.doubleValue())) {
            this.ʼ = -1;
            this.ᐝ = f;
            return this.ʼ;
        } else if (this.ʼ == -1 && ((double) (f - this.ᐝ)) > ˎ.doubleValue()) {
            this.ʼ = 1;
        }
        this.ᐝ = f;
        return this.ʼ;
    }

    public void ˏ(String str) {
        this.ॱ = str;
    }
}
